import unittest
from page.y_order_page import PageOrder
from parameterized import parameterized
from tools.y_get_data import get_cookies

url = 'http://192.168.8.222/admin.php'


class TestOrderManager(unittest.TestCase):
    manager_test = None

    @classmethod
    def setUpClass(cls):
        cls.manager_test = PageOrder(url)
        cls.manager_test.driver.add_cookie(
            get_cookies()
        )
        cls.manager_test.driver.refresh()
        cls.manager_test.click_a()
        cls.manager_test.click_manager()
        cls.manager_test.to_iframe()

    @classmethod
    def tearDownClass(cls):
        cls.manager_test.driver.quit()

    @parameterized.expand(
        [
            ("123", "123", 2, 2, (10, 20), (20, 50), (60, 80), 2, 2, "123")
            # ("123", "123", 2, 2, "123", (20, 50), (60, 80), "123", 2, "123", "123")
        ]
    )
    def test_order_manager(self, order_id, info, order_state, pay_state, money, pay, price, schema, source, address):
        self.manager_test.order_manager_search(order_id, info, order_state, pay_state, money, pay, price, schema,
                                               source, address)


class TestOrderAfter(unittest.TestCase):
    after_test = None

    @classmethod
    def setUpClass(cls):
        cls.after_test = PageOrder(url)
        cls.after_test.driver.add_cookie(
            get_cookies()
        )
        cls.after_test.driver.refresh()
        cls.after_test.click_a()
        cls.after_test.click_after()
        cls.after_test.to_iframe()

    @classmethod
    def tearDownClass(cls):
        cls.after_test.driver.quit()

    @parameterized.expand(
        [
            # ("123", "123", 2, 2, (10, 20), (20, 50), (60, 80), 2, 2, "123")
            ("123", "123", 2, 2, "123", (20, 50), (60, 80), "123", 2, "123", "123")
        ]
    )
    def test_order_manager(self, order_id, info, order_state, pay_state, cause, pay, price, refund_explain, refund_type,
                           courier_services,
                           courier_number):
        self.after_test.order_after_search(order_id, info, order_state, pay_state, cause, pay, price, refund_explain,
                                           refund_type, courier_services,
                                           courier_number)
